import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_utils/flutter_utils.dart';

void main() {
  group('list utils test', () {
    test('test splitByLength', () {
      final list = Iterable.generate(30, (index) => index).toList();
      var splitList1 = list.splitByLength(3);
      var splitList2 = list.splitByLength(4);
      var splitList3 = list.splitByLength(1);
      expect(splitList1.last.length, 3);
      expect(splitList1.length, 10);
      expect(splitList2.length, 8);
      expect(splitList2.last.length, 2);
      expect(splitList3.length, 30);
    });
  });

  group('test NumListExt', () {
    test('test sum', () {
      final list = <double>[1, 3, 5, 7, 9];
      expect(list.sum(), 25);
      expect(list.sum(), 25.0);
      expect(<num>[].sum(), 0);
    });
    test('test avg', () {
      final list = <double>[1, 3, 5, 7, 9];
      expect(list.avg(), 5);
      expect(<num>[].avg(), 0);
    });
  });
}
